package bookdata.tofile;

import java.io.DataOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.oocl.dao.pojo.Book;

public class BookdataToFile {

	public void bookDataToFile() throws Exception {
		FileOutputStream fOut = new FileOutputStream("book.data");
		ObjectOutputStream oOut = new ObjectOutputStream(fOut);
		List<Book> bList = getBookData();
		oOut.writeObject(bList);
		
		oOut.close();
	}

	public List<Book> getBookData() {
		List<Book> bList = new ArrayList<Book>();
		Book[] book = new Book[10000];
		for (int i = 0; i < 10000; i++) {
			book[i]=new Book(i, "Java" + i, new Date(), "Weir" + i, 35.45, true, "机械出版社");
			bList.add(book[i]);
		}
		return bList;

	}
	
	public static void main(String[] args) throws Exception {
		BookdataToFile b=new BookdataToFile();
		b.bookDataToFile();
	}

}
